-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IOPAY-402] update node 14 & fp-ts #320
Conversation
|
fp-ts version |
required typescript version |
---|---|
2.0.x+ | 3.5+ |
1.15.x+ | 3.1+ |
<= 1.14.4 | 2.8+ (*) |
(*) If you are running < typescript@3.0.1
you have to polyfill the unknown
type. You can use unknown-ts as a polyfill.
Documentation
Disclaimer. Teaching functional programming is out of scope of this project, so the documentation assumes you already know what FP is.
- Docs
- Learning Resources
- Ecosystem
- API Reference
Help
If you need help with fp-ts
check out:
- this Discord server
- the
#fp-ts
channel on FP slack.
Development
License
The MIT License (MIT)
eslint-plugin-prettier | Used in package.json | |
Author: Teddy Katz | Description: Runs prettier as an eslint rule | |
License: MIT | Homepage: https://github.com/prettier/eslint-plugin-prettier#readme | |
Keywords: eslint, eslintplugin, eslint-plugin and prettier | ||
Updated: 4 months ago | Created: almost 5 years ago | |
Releases: 28 | Maintainers: 4 | |
Direct Dependencies: prettier-linter-helpers |
README
eslint-plugin-prettier ![Build Status](https://github.com/prettier/eslint-plugin-prettier/workflows/CI/badge.svg?branch=master)
Runs Prettier as an ESLint rule and reports differences as individual ESLint issues.
If your desired formatting does not match Prettier’s output, you should use a different tool such as prettier-eslint instead.
Please read Integrating with linters before installing.
Sample
error: Insert `,` (prettier/prettier) at pkg/commons-atom/ActiveEditorRegistry.js:22:25:
20 | import {
21 | observeActiveEditorsDebounced,
> 22 | editorChangesDebounced
| ^
23 | } from './debounced';;
24 |
25 | import {observableFromSubscribeFunction} from '../commons-node/event';
error: Delete `;` (prettier/prettier) at pkg/commons-atom/ActiveEditorRegistry.js:23:21:
21 | observeActiveEditorsDebounced,
22 | editorChangesDebounced
> 23 | } from './debounced';;
| ^
24 |
25 | import {observableFromSubscribeFunction} from '../commons-node/event';
26 | import {cacheWhileSubscribed} from '../commons-node/observable';
2 errors found.
./node_modules/.bin/eslint --format codeframe pkg/commons-atom/ActiveEditorRegistry.js
(code from nuclide).
Installation
npm install --save-dev eslint-plugin-prettier
npm install --save-dev --save-exact prettier
eslint-plugin-prettier
does not install Prettier or ESLint for you. You must install these yourself.
Then, in your .eslintrc.json
:
{
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
}
}
Recommended Configuration
This plugin works best if you disable all other ESLint rules relating to code formatting, and only enable rules that detect potential bugs. (If another active ESLint rule disagrees with prettier
about how code should be formatted, it will be impossible to avoid lint errors.) You can use eslint-config-prettier to disable all formatting-related ESLint rules.
This plugin ships with a plugin:prettier/recommended
config that sets up both the plugin and eslint-config-prettier
in one go.
-
In addition to the above installation instructions, install
eslint-config-prettier
:npm install --save-dev eslint-config-prettier
-
Then you need to add
plugin:prettier/recommended
as the last extension in your.eslintrc.json
:{ "extends": ["plugin:prettier/recommended"] }
You can then set Prettier's own options inside a
.prettierrc
file.
Exactly what does plugin:prettier/recommended
do? Well, this is what it expands to:
{
"extends": ["prettier"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"arrow-body-style": "off",
"prefer-arrow-callback": "off"
}
}
"extends": ["prettier"]
enables the config fromeslint-config-prettier
, which turns off some ESLint rules that conflict with Prettier."plugins": ["prettier"]
registers this plugin."prettier/prettier": "error"
turns on the rule provided by this plugin, which runs Prettier from within ESLint."arrow-body-style": "off"
and"prefer-arrow-callback": "off"
turns off two ESLint core rules that unfortunately are problematic with this plugin – see the next section.
arrow-body-style
and prefer-arrow-callback
issue
If you use arrow-body-style or prefer-arrow-callback together with the prettier/prettier
rule from this plugin, you can in some cases end up with invalid code due to a bug in ESLint’s autofix – see issue #65.
For this reason, it’s recommended to turn off these rules. The plugin:prettier/recommended
config does that for you.
You can still use these rules together with this plugin if you want, because the bug does not occur all the time. But if you do, you need to keep in mind that you might end up with invalid code, where you manually have to insert a missing closing parenthesis to get going again.
If you’re fixing large of amounts of previously unformatted code, consider temporarily disabling the prettier/prettier
rule and running eslint --fix
and prettier --write
separately.
Options
Note: While it is possible to pass options to Prettier via your ESLint configuration file, it is not recommended because editor extensions such as
prettier-atom
andprettier-vscode
will read.prettierrc
, but won't read settings from ESLint, which can lead to an inconsistent experience.
-
The first option:
-
An object representing options that will be passed into prettier. Example:
"prettier/prettier": ["error", {"singleQuote": true, "parser": "flow"}]
NB: This option will merge and override any config set with
.prettierrc
files
-
-
The second option:
-
An object with the following options
-
usePrettierrc
: Enables loading of the Prettier configuration file, (default:true
). May be useful if you are using multiple tools that conflict with each other, or do not wish to mix your ESLint settings with your Prettier configuration."prettier/prettier": ["error", {}, { "usePrettierrc": false }]
-
fileInfoOptions
: Options that are passed to prettier.getFileInfo to decide whether a file needs to be formatted. Can be used for example to opt-out from ignoring files located innode_modules
directories."prettier/prettier": ["error", {}, { "fileInfoOptions": { "withNodeModules": true } }]
-
-
-
The rule is autofixable -- if you run
eslint
with the--fix
flag, your code will be formatted according toprettier
style.
Contributing
See CONTRIBUTING.md
@pagopa/ts-commons | Used in package.json |
Author: https://www.pagopa.gov.it | Description: Shared TypeScript code for the IO project |
License: MIT | Homepage: https://github.com/pagopa/io-ts-commons#readme |
Updated: 3 months ago | Created: 12 months ago |
Releases: 14 | Maintainers: 4 |
README
TypeScript Commons
This module provides code shared by the projects of the
IO App
initiative.
Documentation is available here
Contributing
In the following there are instructions to build the app in your computer for development purposes.
Pre-requisites
We built a script for helping setting up the laptop, you can find it here
Otherwise, please follow the following steps:
Install NodeJS
To run the project you need to install a properly version of NodeJS.
On macOS and Linux we recommend the use of a virtual environment, such as nodenv for managing multiple versions of NodeJS.
The node version used in this project is stored in .node-version.
If you already have nodenv installed and configured on your system, the correct version node will be set when you access the app directory.
To install, follow the steps described below.
Install brew
If you do not have it already, install brew following the installation instructions in the home page.
Install nodenv
brew install nodenv
Install yarn
For the management of javascript dependencies we use Yarn.
Yarn is a node application. IF you have already installed in your system version of node compatible with yarn, you can install it as a global command with:
npm install -g yarn
Install dependencies
Install the libraries used by the project:
$ yarn install --frozen-lockfile
Run Tests
Run Unit Tests
$ yarn test
Run Lint Check
$ yarn lint
Updating/publishing online docs
$ yarn docs
Releasing a version
Release has been automatized by using Azure Pipelines.
To release a new version please go to io-ts-commons project on Azure and manually run pagopa.io-ts-commons.deploy the pipeline.
Be aware to choose the right release version between major|minor|patch
License
@pagopa/openapi-codegen-ts | Used in package.json |
Author: https://www.pagopa.gov.it/ | Description: Tools and utilities for the IO project |
License: MIT | Homepage: https://github.com/pagopa/io-utils#readme |
Updated: about 1 month ago | Created: 12 months ago |
Releases: 14 | Maintainers: 4 |
@pagopa/eslint-config | Used in package.json |
Author: Unknown | Description: This package provide the following ESLint custom rules for Typescript projects. |
License: MIT | Homepage: https://github.com/pagopa/eslint-rules#readme |
Updated: 3 months ago | Created: 12 months ago |
Releases: 6 | Maintainers: 4 |
README
PagoPA ESLint config
This package provide the following ESLint custom rules for Typescript projects.
recommendend
react
strong
This repository replace italia-tslint-rules after TSLint deprecation.
The following TSLint rules (included inside italia-tslint-rules
) are not supported for eslint at the moment and are missing in this package:
bool-param-default
max-union-size
no-accessor-field-mismatch
no-array-delete // Mitigated by no-delete
no-case-with-or
no-dead-store
no-duplicate-in-composite
no-empty-array
no-extra-semicolon // Mitigated by prettier
no-empty-destructuring // Mititgated by no-empty-pattern
no-gratuitous-expressions
no-hardcoded-credentials
no-ignored-initial-value // Mitigated by no-param-reassign, no-let
no-in-misuse
no-inferred-empty-object-type
no-invalid-await // Mititgated by await-thenable
no-invariant-return
no-misleading-array-reverse // Mitigated by immutable-data
no-misspelled-operator // Mitigated by prettier
no-nested-switch
no-nested-template-literals
no-statements-same-line // Mitigated by prettier
no-try-promise
no-tslint-disable-all
no-unconditional-jump
no-undefined-argument
no-unenclosed-multiline-block // Mitigated by prettier
no-unthrown-error
no-unused-array // Mitigated by no-unused-vars
no-useless-increment
no-useless-intersection
prefer-promise-shorthand
promise-must-complete
use-primitive-type
This list has been produced following these steps:
- Follow TSLint to ESLint migration guide on the project io-backend
- Running
npx tslint-to-eslint-config
that produces a list of TSLint rules not available for ESLint (77 rules at the moment) - Manually check each one for an alternative ESLint rules/plugins
- Verify each alternative ESLint rule/plugin on a testing file
Usage
Installation and Configuration
To use this package install as devDependecy inside any typescript project with
yarn install -D @pagopa/eslint-config
Create on the project an .eslintrc.js
file with the following content
module.exports = {
"extends": [
"@pagopa/eslint-config/strong",
],
"rules": {
// Any project level custom rule
}
}
Add inside the package.json
file a lint
and optionally a lint-autofix
script as:
"scripts": {
"lint": "eslint . -c .eslintrc.js --ext .ts,.tsx",
"lint-autofix": "eslint . -c .eslintrc.js --ext .ts,.tsx --fix",
...
}
Migration from TSLint
Remove from the package.json
every tslint reference:
tslint
italia-tslint-rules
Replace all the // tslint:disable-next-line
with the proper // eslint-disable-next-line
comment. If are present some // tslint:disable
replace it with /* eslint-disable */
at the top of the file.
If you need to disable ESLint for some files create .eslintignore
file with the list of folders or files that must be excluded from lint process. Copy the exclusion from tslint.json
linterOptions.exclude
Delete all tslint related files (es. tslint.json
).
Run yarn lint-autofix
to refactorize the code automatically with all the auto-fixable ESLint rules.
New dependencies added: @pagopa/eslint-config
, @pagopa/openapi-codegen-ts
, @pagopa/ts-commons
, eslint-plugin-prettier
and fp-ts
.
Example of PR titles that include pivotal stories:
- single story:
[#123456] my PR title
- multiple stories:
[#123456,#123457,#123458] my PR title
@giovanniberti @MarcoAGreco the goal is to run pipeline in you have to change the yaml prefix with pagopa, so:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work 🚀
.devops/deploy-pipelines.yml
Outdated
- download: current | ||
artifact: Bundle | ||
|
||
- job: waitStartup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this necessary to wait proxy get up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, thanks
package.json
Outdated
"prettify": "prettier --write \"./**/*.ts\"", | ||
"start": "node dist/src/index.js", | ||
"test:coverage": "jest --runInBand --coverage", | ||
"test:integration": "jest --config=jest.integration.js --runInBand", | ||
"test:coverage": "jest --runInBand --coverage --detectOpenHandles", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with --detectOpenHandles
option , when i runs test i retrieve the following nasty warning message
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
● TCPWRAP
is it correct to display it? or is there a way to disable it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added for some debugging, but we can disable, thanks
.devops/deploy-pipelines.yml
Outdated
targetType: filePath | ||
filePath: k6example/ws.sh | ||
arguments: postman | ||
workingDirectory: k6example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be better to rename k6example
folder in to api-test
Very good and really important upgrade! thank you @infantesimone! |
In order to leave the master branch aligned with the |
List of Changes
node 14.16.0
io-ts 2.2.16
fp-ts 2.11.1
jest 27
tslint
-->eslint
fp-ts 2.11.1
Motivation and Context
The goal of this PR is to update some critical dependences, before porting the
pagopa-proxy
from thePROD-IO
to thepagoPA
Azure subscription (according to this RFC).How Has This Been Tested?
Types of changes
Checklist: